package sistema.validador;
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 29/3/2006 21:06:19
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   DiffIgnoreSpaceCarriage.java

import java.io.*;

class DiffIgnoreSpaceCarriage extends Diff
{

    DiffIgnoreSpaceCarriage()
    {
    }

    public void close()
        throws IOException
    {
        pr.close();
    }

    public String diff_iniSpCar(PushbackReader pr)
        throws IOException
    {
        StringBuffer sb;
label0:
        {
            boolean type = true;
            int c;
            char ch;
            do
            {
                c = pr.read();
                if(c == -1)
                    return null;
                ch = (char)c;
                if(c >= 33 && c <= 129)
                    type = false;
            } while(type);
            sb = new StringBuffer();
            sb.append(ch);
            do
            {
                c = pr.read();
                if(c == -1)
                    break label0;
                ch = (char)c;
                if(c < 33 || c > 129)
                    break;
                sb.append(ch);
            } while(true);
            pr.unread(c);
        }
        return sb.toString();
    }

    public void diffIniSpCar(FileReader fr, String temp1, PrintWriter log)
        throws IOException
    {
        BufferedReader br = new BufferedReader(fr);
        pr = new PushbackReader(br, 1);
        try
        {
            PrintWriter pw = new PrintWriter(new FileOutputStream(temp1), true);
            log.println("-------------------------*** EXECUTING DIFF IGNORE SPACE  CARRIAGE  ***---------------------------");
            log.println("-------------------------***WRITING IN  TEMP FILE (" + temp1 + ")***-----------------------");
            String token;
            while((token = diff_iniSpCar(pr)) != null) 
            {
                pw.println(token.toLowerCase());
                log.println(token.toLowerCase());
            }
        }
        catch(IOException e)
        {
            System.out.println("FAILED TO WRITE TO THE TEMP FILE (" + temp1 + ")" + e.toString());
            log.println("FAILED TO WRITE TO THE TEMP FILE (" + temp1 + ")" + e.toString());
        }
    }

    private PushbackReader pr;
}